﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace pufflesweb
{
    public partial class adpot : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string HID = Request.QueryString["HID"];

                PModel.Help help = PBLL.Help.Getuser(int.Parse(HID));

                PModel.User mysuer = new PModel.User();

                mysuer = (PModel.User)PF.SessionHelper.GetSession("user");

                this.HiddenField1.Value = mysuer.UID.ToString();
                //this.hname.Text = help.Hname;
                //this.hsex.Text = help.Hsex.ToString();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            PModel.Adopt adopt = new PModel.Adopt();
            PModel.User myuser = new PModel.User();
            myuser = (PModel.User)PF.SessionHelper.GetSession("user");
            adopt.User = myuser;
            string HID = Request.QueryString["HID"];
            PModel.Help help = PBLL.Help.Getuser(int.Parse(HID));
            adopt.Help = help;
            //happly.User.UID = int.Parse(this.uid.Text);
            //happly.User.UID = int.Parse(this.HiddenField1.Value);
            adopt.Tname = this.tname.Text.Trim();
            adopt.Tmoney = int.Parse(this.tmoney.Text.Trim());
            adopt.Tusetime = int.Parse(this.tusetime.Text.Trim());
            adopt.Ttext = this.ttext.Text.Trim();
            adopt.Taddress = this.taddress.Text.Trim();
            adopt.Temail = this.temail.Text.Trim();
            adopt.Twechat = this.twechat.Text.Trim();
            adopt.Tqq = int.Parse(this.tqq.Text.Trim());
            adopt.Tphone = int.Parse(this.tphone.Text.Trim());

            if (PBLL.Adopt.add(adopt))
            {
                PF.JsHelper.AlertAndParentUrl("领养申请上传成功", "index.aspx");
            }
            else
            {
                PF.JsHelper.AlertAndParentUrl("领养申请上传失败,请重新输入", "tables.aspx");
            }
        }
    }
}